package com.jarvis.app.car.common;

public class MessageResult<T> {

    private boolean judgeSuccess;

    private String msg;

    private T result;

    public boolean isJudgeSuccess() {
        return judgeSuccess;
    }

    public void setJudgeSuccess(boolean judgeSuccess) {
        this.judgeSuccess = judgeSuccess;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getResult() {
        return result;
    }

    public void setResult(T result) {
        this.result = result;
    }

    public MessageResult() {
    }

    public MessageResult(boolean judgeSuccess, String msg, T result) {
        this.judgeSuccess = judgeSuccess;
        this.msg = msg;
        this.result = result;
    }

    public static MessageResult<Void> ok() {
        return new MessageResult<Void>(true, "操作成功", null);
    }

    public static MessageResult<Void> fail() {
        return new MessageResult<Void>(false, "操作失败", null);
    }

    public static MessageResult<Void> ok(String msg) {
        return new MessageResult<Void>(true, msg, null);
    }

    public static MessageResult<Void> fail(String msg) {
        return new MessageResult<Void>(false, msg, null);
    }

    public static <T> MessageResult<T> ok(String msg, T t) {
        return new MessageResult<T>(true, msg, t);
    }

    public static <T> MessageResult<T> fail(String msg, T t) {
        return new MessageResult<T>(false, msg, t);
    }
}
